/**
 * 
 */
package com.et114.test.ldap4oj;

import java.util.List;

import javax.naming.NamingException;
import javax.naming.directory.Attributes;

import org.springframework.ldap.core.AttributesMapper;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;

import com.et114.components.junit.BaseTestCase;

/**
 * @author Administrator
 *
 */
public class LdapTestSpring206 extends BaseTestCase {

	public void test()  {
		
		LdapContextSource ucs = new LdapContextSource( ) ;
		ucs.setUrl ( "ldap://localhost:389" );
		ucs.setUserDn ( "cn=Manager,dc=example,dc=com" );
		ucs.setPassword ( "secret" );
		ucs.setBase ( "dc=example,dc=com" ) ;
		ucs.setPooled ( false ) ;
		ucs.setCacheEnvironmentProperties ( false ) ;
		
		LdapTemplate ldap = new LdapTemplate ( ucs );
		List result = ldap.search ( "" , "ou=pepole" , new AttributesMapper ( ) {
			public Object mapFromAttributes ( Attributes attrs )
					throws NamingException , javax.naming.NamingException {
				return attrs.get ( "ou" ).get ( );
			}
		} );
	
		logger.info ( ".." + result ) ;
	}
}
